<link rel="stylesheet" type="text/css" href="style.css" />
<?php
  session_start(); 
 require_once('db.class.php'); 
 
 
 class Member{

//untuk mengecek apa sudah login atau belum
  function cek_login(){
	$hasil = 0;
	
	$mail = $_SESSION['email'];
	$pass = $_SESSION['pass'];
	
	if (!empty($mail) and !empty($pass)){
		$hasil = 1;
	}
	
	return $hasil;
  }
  
  // mendapatkan nama member
  function get_nama(){
	$mail = $_SESSION['email'];
	
	global $db;
	$sql     = "select * from member where email='$mail'";
	$query = $db->query($sql);
	
	$data    = mysql_fetch_array($query);
	
	return $data['nama'];
	
  }
  
  function get_email_ses(){
	$mail = $_SESSION['email'];
	
	return $mail;
  }
  
 // fungsi untuk mendapatkan idpesanan dari idmember
 function get_id_pesanan($id_member){
$id 	 = $id_member;
global $db;
	$sql 	 = "select * from pesanan where id_member='$id' and dichekout='T'";
	$q = $db->query($sql);
	$f  	 = mysql_fetch_array($q);
	
	return $f['id_pesanan'];
  }
  
  // fungsi untuk mengecek, apa member mempunyai keranjang yang belum dichekout atau tidak
  function punya_pesanan($id_member){
	global $db;
	$sql = "select * from pesanan where id_member='$id_member' and dichekout='T'";
	$q = $db->query($sql);
	$n   = mysql_num_rows($q);
	$f   = mysql_fetch_array($q);
		
	if($n!=0){ // berarti ada pesanan yang belum dichekout
		return $f['id_pesanan'];
	}else{
		$id_pesanan = 0;
		return $id_pesanan;
	}
  }
  
  // proses pengecekan email yang sama
  function cekEmailSama($m){
    $mail = $m;
   global $db;
	$sql = "select * from member where email='$mail'";
	$res= $db->query($sql);
	$jml = mysql_num_rows($res);
	$hasil = 0;
	
	if ($jml>0) {
	  $hasil = 1;
	}
	
	return $hasil;
  }
  
  }
  
  